package com.angel.webapp.application;

import com.angel.common.keyValue.KeyValueResult;
import com.angel.common.keyValue.impl.KeyValueResultImpl;
import com.angel.io.processors.commands.exports.ExportRowProcessorCommand;

/**
 * @author William
 * @since 03/February/2009
 */
public class ApplicationExportRowCommands {

    private static ApplicationExportRowCommands INSTANCE;

    private KeyValueResult keyValueResult;

    private ApplicationExportRowCommands(){
        super();
        this.setKeyValueResult(new KeyValueResultImpl());
    }

    public synchronized static ApplicationExportRowCommands createInstance(){
        if(INSTANCE == null){
            INSTANCE = new ApplicationExportRowCommands();
        }
        return INSTANCE;
    }

    public KeyValueResult getKeyValueResult() {
        return keyValueResult;
    }

    public void setKeyValueResult(KeyValueResult keyValueResult) {
        this.keyValueResult = keyValueResult;
    }

    public ExportRowProcessorCommand findExportRowCommand(String name){
        return (ExportRowProcessorCommand) this.getKeyValueResult().getResultFor(name);
    }
    
    public void addExportRowCommand(String name, ExportRowProcessorCommand exportRowProcessorCommand){
        this.getKeyValueResult().addKeyValue(name, exportRowProcessorCommand);
    }
    
    public void removeExportRowCommand(String name, ExportRowProcessorCommand exportRowProcessorCommand){
        this.getKeyValueResult().removeKeyValue(name);
    }

    public boolean containsExportRowCommand(String name){
        return this.keyValueResult.containsResultFor(name);
    }
}